# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
# This source file is part of the Cangjie project, licensed under Apache-2.0
# with Runtime Library Exception.
#
# See https://cangjie-lang.cn/pages/LICENSE for license information.

from os import path

dir = path.dirname(path.realpath(__file__))
path = dir + '/test_' + path.basename(dir) + '_{}.cj'
template = '''
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
 * This source file is part of the Cangjie project, licensed under Apache-2.0
 * with Runtime Library Exception.
 *
 * See https://cangjie-lang.cn/pages/LICENSE for license information.
 */

/*
  @Assertion:   10.2.3(14)  1. Except for the operators listed in the above table, the other operators (see Section
                1.4 for a complete list of operators) do not support to be overloaded.
  @Description: Checks that {op} cannot be overloaded.
  @Mode: compileonly
  @Negative: yes
  @Structure: single
  @CompileWarning: ignore
  @Comment: Auto-generated by gen.py
*/

class C {{
    operator func {op}({}) {{ }}
}}

main() {{ }}
'''
counter = 1

def write_counted(contents : str):
  global counter
  with open(path.format(str(counter).zfill(2)), 'w') as file:
    file.write(contents)
    counter += 1

unary_ops = ['@', '++', '--']
binary_ops = ['.', '?', 'is', 'as', '..', '..=', '&&', '||', '??', '|>', '~>',
              '=', '**=', '*=', '/=', '%=', '+=', '-=', '<<=', '>>=', '&=', '^=', '|=', '&&=', '||=']
for test in [template.format('', op=op) for op in unary_ops] + [template.format('other : C', op=op) for op in binary_ops]:
  write_counted(test)
